package com.hnucm.c202001020216.ui.fragment;

import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.VideoView;

import androidx.fragment.app.Fragment;

import com.hnucm.c202001020216.R;



/**
 * @author starr
 */
public class ScienceFragment extends Fragment {


    VideoView videoView;
    ImageView shareBtn;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_science, container, false);

        shareBtn = view.findViewById(R.id.imageView14);

       /* shareBtn.setOnClickListener(
                (view1)->{x
                    Intent intent=new Intent(getActivity(),ShareActivity.class);
                    startActivity(intent);
                }
        );*/
        videoView = view.findViewById(R.id.videoView1);
        //加载视频
        //videoView.setVideoURI(Uri.parse("android.resource://" + requireActivity().getPackageName() + "/raw/" + R.raw.a2));
        //加载网络视频
        String videoPath = "http://vfx.mtime.cn/Video/2019/07/12/mp4/190712140656051701.mp4";
        videoView.setVideoPath(videoPath);
        //设置进度条
        videoView.setMediaController(new MediaController(getContext()));
        videoView.start();

        videoView.setOnClickListener(view1 -> {
            if (videoView.isPlaying()) {
                videoView.pause();
            } else {
                videoView.start();
            }
        });
        return view;
    }
}